package com.itcat.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itcat.mysql.pojo.UmsAdmin;
import com.itcat.mysql.pojo.UmsRole;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

/**
 * [一句话描述该类的功能]
 *
 * @author : [Cr Mr]
 * @version : [v1.0]
 * @date : [2022/3/31 17:34]
 */
@Mapper
public interface UmsAdminMapper extends BaseMapper<UmsAdmin> {
    @Insert("<script>" +
            "INSERT INTO ums_admin_role_relation (admin_id,role_id) values" +
            "<foreach collection=\"items\" index=\"index\" item=\"item\" separator=\",\"> " +
            "(#{adminId},#{item})" +
            "</foreach> " +
            "</script>")
    void insertReoles(@Param("adminId") Long adminId, @Param("items") Long[] items);

    @Delete("DELETE FROM ums_admin_role_relation WHERE admin_id=#{adminId}")
    void deleteReoles(Long adminId);
}
